import java.util.Iterator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;

public class Other {

    //前k个最大值
    public int[] maxK(int[] array, int k){
        int[] ret = new int[k];
        if (array == null || k == 0){
            return ret;
        }
        Queue<Integer> priorityQueue = new PriorityQueue<>(k);
        for (int i = 0; i < k; i++){
            priorityQueue.offer(array[i]);
        }
        for (int i = k; i < array.length; i++){
            if (priorityQueue.peek() < array[i]){
                priorityQueue.poll();
                priorityQueue.offer(array[i]);
            }
        }
        for (int i = 0; i < ret.length; i++){
            ret[i] = priorityQueue.poll();
        }
        return ret;
    }
}
